/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//

// ns3 - On/Off Data Source Application class
// George F. Riley, Georgia Tech, Spring 2007
// Adapted from ApplicationFlow in GTNetS.

#ifndef __flow_client_application_h__
#define __flow_client_application_h__

#include "ns3/application.h"
#include "ns3/random-variable.h"
#include "ns3/traced-callback.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/uinteger.h"

#include "flow-client.h"

namespace ns3 {

/*
class SingleDestFlowClient : public Object
{
  static TypeId GetTypeId (void);
public:
  SingleDestFlowClient (Address const &local, Address const &remote));
  ~SingleDestFlowClient ();

  void SetFlowNum (uint32_t);
  void SetFlowStartCallback();
  void SetFlowFinishCallback();

private:
  Address         m_remote;       // Remote address
  Address         m_local;        // Local address

  uint32_t        m_flowCount;      // current number of concurrent flows
  uint32_t        m_flowNum;        // max number of concurrent flows
  uint32_t        m_flowBurst;      // maximum increment in number of flows

  std::list<Ptr<FlowClient> >     m_flowList;   //the accepted sockets
};
*/

class FlowClientApplication : public Application 
{
public:
  static TypeId GetTypeId (void);

  FlowClientApplication ();
  virtual ~FlowClientApplication();
  void StartFlows();
  void StartFlow();

  Address GetRemote() const;

protected:
  virtual void DoDispose (void);
private:
  // inherited from Application base class.
  virtual void StartApplication (void);    // Called at time specified by Start
  virtual void StopApplication (void);     // Called at time specified by Stop

  void HandleFlowFinish (Ptr<FlowClient>);

  Address         m_remote;       // Remote address
  Address         m_local;        // Local address
  RandomVariable  m_flowSize;     // Flow size

  uint32_t        m_flowCount;      // current number of concurrent flows
  uint32_t        m_flowNum;        // max number of concurrent flows
  uint32_t        m_flowBurst;      // maximum increment in number of flows

  std::list<Ptr<FlowClient> >     m_flowList;   //the accepted sockets

  TracedCallback<uint32_t > m_flowCountUpdate;
};

} // namespace ns3

#endif

